<?php

namespace common\models\datas;

use common\components\behaviors\UpdateCacheBehavior;
use Yii;
use yii\helpers\ArrayHelper;

/**
 * This is the model class for table "{{%web_sales}}".
 *
 * @property integer $id
 * @property string $title
 * @property string $subtitle
 * @property integer $category_id
 * @property string $category_name
 * @property string $info
 * @property string $content
 * @property string $price
 * @property string $cost
 * @property integer $distribution_way
 * @property integer $distribution_proportion
 * @property integer $total_stock
 * @property integer $mechanic_id
 * @property string $code
 * @property integer $state
 * @property integer $user_id
 * @property integer $created_at
 * @property string $images
 * @property integer $city_id
 * @property integer $site_id
 * @property integer $type
 * @property integer $recommend
 * @property integer $sort
 * @property integer $course_id
 * @property integer $teacher_id
 * @property integer $classroom_id
 * @property string $class_time
 * @property string $class_length
 * @property string $class_day
 * @property string $class_count
 * @property integer $max_number
 * @property integer $opening_number
 * @property integer $is_book
 * @property integer $status
 * @property integer $states
 * @property string $deposit
 */
class WebSales extends \common\components\bases\BaseModel
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%web_sales}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['classroom_attr_id','class_day','start_time','end_time','class_count','class_length','type','recommend','category_id', 'distribution_way', 'distribution_proportion', 'total_stock', 'mechanic_id', 'state', 'user_id', 'created_at', 'type','city_id','site_id','sort','course_id','teacher_id','classroom_id','is_book','status','states'], 'integer'],
            [['max_number','opening_number','info', 'content','teacher_name'], 'string'],
            [['price', 'cost','deposit'], 'number'],
            [['title', 'subtitle', 'category_name', 'arrange_course_id','teacher_img','teache_form'], 'string', 'max' => 255],
            [['images'], 'string', 'max' => 64]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('common', 'ID'),
            'title' => Yii::t('common', '标题'),
            'subtitle' => Yii::t('common', '子标题'),
            'category_id' => Yii::t('common', '类别ID'),
            'category_name' => Yii::t('common', '类别名称'),
            'info' => Yii::t('common', '描述信息'),
            'content' => Yii::t('common', '详情'),
            'price' => Yii::t('common', '销售价'),
            'cost' => Yii::t('common', '成本价'),
            'distribution_way' => Yii::t('common', '分成方式'),
            'distribution_proportion' => Yii::t('common', '分成比例'),
            'total_stock' => Yii::t('common', '库存总量'),
            'mechanic_id' => Yii::t('common', '所属机构'),
            'code' => Yii::t('common', '商品编码'),
            'state' => Yii::t('common', '商品状态'),
            'user_id' => Yii::t('common', '创建用户ID'),
            'created_at' => Yii::t('common', '创建时间'),
            'images' => Yii::t('common', '产品展示图'),
            'city_id' => Yii::t('common', '城市ID'),
            'site_id' => Yii::t('common', '广场ID'),
            'type' => Yii::t('common', '类型'),
            'recommend' => Yii::t('common', '推荐'),
            'sort' => Yii::t('common', '排序'),
            'teache_form' => Yii::t('common', '排序'),
            'sort' => Yii::t('common', '排序'),
        ];
    }

    public function behaviors(){
        return ArrayHelper::merge(parent::behaviors(),[
            [
                'class'=>UpdateCacheBehavior::className(),
                'cacheName'=>'categorysales'
            ]
        ]);
    }
}
